package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysIntegral;
import com.ruoyi.project.system.service.ISysIntegralService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 积分明细Controller
 * 
 * @author jjp
 * @date 2020-04-27
 */
@RestController
@Api("积分明细")
@RequestMapping("/system/integral")
public class SysIntegralController extends BaseController
{
    @Autowired
    private ISysIntegralService sysIntegralService;

    /**
     * 查询积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:integral:list')")
    @ApiOperation("查询积分明细列表")
    @GetMapping("/list")
    public TableDataInfo list(SysIntegral sysIntegral)
    {
        startPage();
        List<SysIntegral> list = sysIntegralService.selectSysIntegralList(sysIntegral);
        return getDataTable(list);
    }

    /**
     * 获取积分明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:integral:query')")
    @ApiOperation("获取积分明细详细信息")
    @GetMapping(value = "/{integralId}")
    public AjaxResult getInfo(@PathVariable("integralId") Long integralId)
    {
        return AjaxResult.success(sysIntegralService.selectSysIntegralById(integralId));
    }

    /**
     * 新增积分明细
     */
    @PreAuthorize("@ss.hasPermi('system:integral:add')")
    @ApiOperation("新增积分明细")
    @Log(title = "积分明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysIntegral sysIntegral)
    {
        return toAjax(sysIntegralService.insertSysIntegral(sysIntegral));
    }

    /**
     * 修改积分明细
     */
    @PreAuthorize("@ss.hasPermi('system:integral:edit')")
    @ApiOperation("修改积分明细")
    @Log(title = "积分明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysIntegral sysIntegral)
    {
        return toAjax(sysIntegralService.updateSysIntegral(sysIntegral));
    }

    /**
     * 删除积分明细
     */
    @PreAuthorize("@ss.hasPermi('system:integral:remove')")
    @ApiOperation("删除积分明细")
    @Log(title = "积分明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{integralIds}")
    public AjaxResult remove(@PathVariable Long[] integralIds)
    {
        return toAjax(sysIntegralService.deleteSysIntegralByIds(integralIds));
    }
}
